﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Samurai.Infrastructure;

namespace Samurai.Client
{
    internal class RefreshNonMoviesCommand : ICommand
    {
        private readonly ObservableCollection<Movie> _nonMovies;

        public RefreshNonMoviesCommand(ObservableCollection<Movie> nonMovies)
        {
            _nonMovies = nonMovies;
        }

        public void Execute(object parameter)
        {
            _nonMovies.Clear();

            IEnumerable<Movie> nonMovies = DAL.Manager.Instance.GetNonMovies();

            foreach (var movieData in nonMovies)
            {
                _nonMovies.Add(movieData);
            }
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;
    }
}